package com.tangmu.rabbits.app;

import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;

/**
 * Created by Administrator on 2017/7/5.
 */

public class BaseApplication extends Application {

    private static BaseApplication baseApplication;
    //
    public static String city;


    @Override
    public void onCreate() {
        super.onCreate();
        baseApplication = this;

    }

    public static BaseApplication getAppContext() {
        return baseApplication;
    }

    public static Resources getReouces() {
        return baseApplication.getResources();
    }

    /**
     * 获取应用版本号，默认返回1
     *
     * @return
     */
    public static int getAppVersionCode() {
        Context context = getAppContext();
        try {
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);

            return packageInfo.versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return 1;
    }

}
